# My pseudo code for Exercice 3
# START
#     Initialize second to 0
#     list <- READ a list
#     Make the list in order "sort"
#     first <- list[-1]
#     len <- the length of the list
#     FOUND <- False
#     FOR each item in the list(-2,-len(list)-1,-1):
#         if item < first then:
#             second <- item
#             Display"Output:second"
#             FOUND <- True
#             Break
#         END IF
#     END FOR 
#     IF FOUND=True then:
#         Display:"Explanation: The largest element of the array is first and the second_largest element is {second}."
#     ELIF FOUND =False then:
#         Display:"Explanation: The largest element of the array is first and the second_largest element is -1."
#     END IF
# END 
def SecondLargest(arr):
    arr.sort()
    first=arr[-1]
    Found=False
    for i in range(-2,-len(arr)-1,-1):
        if arr[i]<first:
            second=arr[i]
            Found=True
            break
    if Found==False:
        print(f'Output:{-1}')
        print(f'Explanation: The largest element of the array is {first} and the second largest element is -1.')
    else:
        print(f'Output:{second}')
        print(f'Explanation: The largest element of the array is {first} and the second largest element is {second}.')
SecondLargest([12,35,1,10,34,1])
SecondLargest([10,5,10])